home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / machserver / 1.098 / lfs / lfsDescMap.c < prev    next >
C/C++ Source or Header  |  1991-08-08  |  20KB  |  711 lines

  1. /* 
  2.  * lfsDescMap.c --
  3.  *
  4.  *    Routines providing access fields to the LFS descriptor map.
  5.  *    This modules responsible for cacheing, writing, and checkpointing the
  6.  *    LFS descriptor map for a file system.
  7.  *
  8.  * Copyright 1989 Regents of the University of California
  9.  * Permission to use, copy, modify, and distribute this
  10.  * software and its documentation for any purpose and without
  11.  * fee is hereby granted, provided that the above copyright
  12.  * notice appear in all copies.  The University of California
  13.  * makes no representations about the suitability of this
  14.  * software for any purpose.  It is provided "as is" without
  15.  * express or implied warranty.
  16.  */
  17.  
  18. #ifndef lint
  19. static char rcsid[] = "$Header: /sprite/src/kernel/lfs/RCS/lfsDescMap.c,v 1.7 91/08/08 17:44:41 mendel Exp $ SPRITE (Berkeley)";
  20. #endif /* not lint */
  21.  
  22. #include <sprite.h>
  23. #include <lfs.h>
  24. #include <lfsInt.h>
  25. #include <lfsDescMap.h>
  26. #include <lfsDesc.h>
  27. #include <lfsStableMemInt.h>
  28. #include <lfsSeg.h>
  29. #include <fsutil.h>
  30.  
  31.  
  32. /*
  33.  *----------------------------------------------------------------------
  34.  *
  35.  * LfsDescMapGetVersion --
  36.  *
  37.  *    Return the descriptor map truncate version for the specified
  38.  *    file.
  39.  *
  40.  * Results:
  41.  *    SUCCESS if the entry is resident in the descriptor map.
  42.  *    FS_FILE_NOT_FOUND if the file is not allocated.
  43.  *    GEN_INVALID_ARG if the fileNumber is not available in the map.
  44.  *    
  45.  * Side effects:
  46.  *    None.
  47.  *
  48.  *----------------------------------------------------------------------
  49.  */
  50.  
  51. ReturnStatus
  52. LfsDescMapGetVersion(lfsPtr, fileNumber, versionNumPtr)
  53.     Lfs      *lfsPtr;    /* File system of descriptor. */
  54.     int      fileNumber;   /* File number of descriptor. */ 
  55.     unsigned short  *versionNumPtr; /* Area to return version number in.*/
  56. {
  57.     LfsDescMap          *mapPtr = &(lfsPtr->descMap);
  58.     LfsStableMemEntry smemEntry;
  59.     LfsDescMapEntry   *entryPtr;
  60.     ReturnStatus      status;
  61.  
  62.     status = LfsStableMemFetch(&(mapPtr->stableMem), fileNumber, 0,
  63.         &smemEntry);
  64.     if (status != SUCCESS) {
  65.     return status;
  66.     }
  67.     entryPtr = (LfsDescMapEntry *) LfsStableMemEntryAddr(&smemEntry);
  68.  
  69.     if (!(entryPtr->flags & LFS_DESC_MAP_ALLOCED)) {
  70.     status = FS_FILE_NOT_FOUND;
  71.     } else { 
  72.     *versionNumPtr = entryPtr->truncVersion;
  73.     }
  74.     LfsStableMemRelease(&(mapPtr->stableMem), &smemEntry, FALSE);
  75.     return status;
  76.  
  77. }
  78.  
  79. /*
  80.  *----------------------------------------------------------------------
  81.  *
  82.  * LfsDescMapIncVersion --
  83.  *
  84.  *    Increment the truncate version number for the specified
  85.  *    file.
  86.  *
  87.  * Results:
  88.  *    SUCCESS if the entry is resident in the descriptor map.
  89.  *    GEN_INVALID_ARG if the fileNumber is not available in the map.
  90.  *    
  91.  * Side effects:
  92.  *    Version number of entry increment.
  93.  *
  94.  *----------------------------------------------------------------------
  95.  */
  96.  
  97. ReturnStatus
  98. LfsDescMapIncVersion(lfsPtr, fileNumber, versionPtr)
  99.     Lfs      *lfsPtr;    /* File system of descriptor. */
  100.     int      fileNumber;   /* File number of descriptor. */ 
  101.     int      *versionPtr;  /* OUT: New truncate version number. */
  102. {
  103.     LfsDescMap          *mapPtr = &(lfsPtr->descMap);
  104.     LfsDescMapEntry   *entryPtr;
  105.     ReturnStatus      status;
  106.     LfsStableMemEntry    smemEntry;
  107.  
  108.     status = LfsStableMemFetch(&(mapPtr->stableMem), fileNumber, 
  109.             LFS_STABLE_MEM_MAY_DIRTY, &smemEntry);
  110.     if (status != SUCCESS) {
  111.     return status;
  112.     }
  113.     entryPtr = (LfsDescMapEntry *) LfsStableMemEntryAddr(&smemEntry);
  114.  
  115.     *versionPtr = ++(entryPtr->truncVersion);
  116.     LfsStableMemRelease(&(mapPtr->stableMem), &smemEntry, TRUE);
  117.     return SUCCESS;
  118. }
  119.  
  120. /*
  121.  *----------------------------------------------------------------------
  122.  *
  123.  * LfsDescMapGetDiskAddr --
  124.  *
  125.  *    Return the disk address of the specified descriptor.
  126.  *
  127.  * Results:
  128.  *    SUCCESS if the entry is resident in the descriptor map.
  129.  *    FS_FILE_NOT_FOUND if the file is not allocated.
  130.  *    GEN_INVALID_ARG if the fileNumber is not available in the map.
  131.  *    
  132.  * Side effects:
  133.  *    None.
  134.  *
  135.  *----------------------------------------------------------------------
  136.  */
  137.  
  138. ReturnStatus
  139. LfsDescMapGetDiskAddr(lfsPtr, fileNumber, diskAddrPtr)
  140.     Lfs      *lfsPtr;    /* File system of descriptor. */
  141.     int      fileNumber;   /* File number of descriptor. */ 
  142.     LfsDiskAddr  *diskAddrPtr; /* Current disk address.*/
  143. {
  144.     LfsDescMap          *mapPtr = &(lfsPtr->descMap);
  145.     LfsDescMapEntry   *entryPtr;
  146.     ReturnStatus      status;
  147.     LfsStableMemEntry    smemEntry;
  148.  
  149.     status = LfsStableMemFetch(&(mapPtr->stableMem), fileNumber, 0,
  150.              &smemEntry);
  151.     if (status != SUCCESS) {
  152.     return status;
  153.     }
  154.     entryPtr = (LfsDescMapEntry *) LfsStableMemEntryAddr(&smemEntry);
  155.  
  156.     if (!(entryPtr->flags & LFS_DESC_MAP_ALLOCED)) {
  157.     status = FS_FILE_NOT_FOUND;
  158.     }
  159.     *diskAddrPtr = entryPtr->blockAddress;
  160.     LfsStableMemRelease(&(mapPtr->stableMem), &smemEntry, FALSE);
  161.     return status;
  162.  
  163. }
  164.  
  165. /*
  166.  *----------------------------------------------------------------------
  167.  *
  168.  * LfsDescMapSetDiskAddr --
  169.  *
  170.  *    Set the disk address for the specified descriptor.
  171.  *
  172.  * Results:
  173.  *    SUCCESS if the entry is resident in the descriptor map.
  174.  *    FAILURE if the fileNumber is not available in the map.
  175.  *    
  176.  * Side effects:
  177.  *    None.
  178.  *
  179.  *----------------------------------------------------------------------
  180.  */
  181.  
  182. ReturnStatus
  183. LfsDescMapSetDiskAddr(lfsPtr, fileNumber, diskAddr)
  184.     Lfs      *lfsPtr;    /* File system of descriptor. */
  185.     int      fileNumber;   /* File number of descriptor. */ 
  186.     LfsDiskAddr diskAddr; /* New disk address.*/
  187. {
  188.     LfsDescMap          *mapPtr = &(lfsPtr->descMap);
  189.     LfsDescMapEntry   *entryPtr;
  190.     ReturnStatus    status;
  191.     LfsStableMemEntry    smemEntry;
  192.  
  193.     status = LfsStableMemFetch(&(mapPtr->stableMem), fileNumber, 
  194.                 LFS_STABLE_MEM_MAY_DIRTY, &smemEntry);
  195.     if (status != SUCCESS) {
  196.     return status;
  197.     }
  198.     entryPtr = (LfsDescMapEntry *) LfsStableMemEntryAddr(&smemEntry);
  199.  
  200.     if (!(entryPtr->flags & LFS_DESC_MAP_ALLOCED)) {
  201.     status = FAILURE;
  202.     } else { 
  203.     if (!LfsIsNullDiskAddr(entryPtr->blockAddress)) { 
  204.         LfsSegUsageFreeBlocks(lfsPtr, sizeof(LfsFileDescriptor), 1, 
  205.                   &entryPtr->blockAddress);
  206.         LFS_STATS_INC(lfsPtr->stats.desc.descMoved);
  207.     }
  208.     entryPtr->blockAddress = diskAddr;
  209.     }
  210.     LfsStableMemRelease(&(mapPtr->stableMem), &smemEntry, (status == SUCCESS));
  211.     return status;
  212.  
  213. }
  214.  
  215. /*
  216.  *----------------------------------------------------------------------
  217.  *
  218.  * LfsDescMapGetAccessTime --
  219.  *
  220.  *    Return the file access time for the specified file number.
  221.  *
  222.  * Results:
  223.  *    SUCCESS if the entry is resident in the descriptor map.
  224.  *    FAILURE if the fileNumber is not available in the map.
  225.  *    
  226.  * Side effects:
  227.  *    None.
  228.  *
  229.  *----------------------------------------------------------------------
  230.  */
  231.  
  232. ReturnStatus
  233. LfsDescMapGetAccessTime(lfsPtr, fileNumber, accessTimePtr)
  234.     Lfs      *lfsPtr;    /* File system of descriptor. */
  235.     int      fileNumber;   /* File number of descriptor. */ 
  236.     int  *accessTimePtr; /* Current access time.*/
  237. {
  238.     LfsDescMap          *mapPtr = &(lfsPtr->descMap);
  239.     LfsDescMapEntry   *entryPtr;
  240.     ReturnStatus      status;
  241.     LfsStableMemEntry    smemEntry;
  242.  
  243.     status = LfsStableMemFetch(&(mapPtr->stableMem), fileNumber, 0, 
  244.                 &smemEntry);
  245.     if (status != SUCCESS) {
  246.     return status;
  247.     }
  248.     entryPtr = (LfsDescMapEntry *) LfsStableMemEntryAddr(&smemEntry);
  249.  
  250.     if (!(entryPtr->flags & LFS_DESC_MAP_ALLOCED)) {
  251.     status = FAILURE;
  252.     }
  253.     *accessTimePtr = entryPtr->accessTime;
  254.     LfsStableMemRelease(&(mapPtr->stableMem), &smemEntry, FALSE);
  255.     return status;
  256.  
  257. }
  258.  
  259. /*
  260.  *----------------------------------------------------------------------
  261.  *
  262.  * LfsDescMapSetAccessTime --
  263.  *
  264.  *    Set the file access time for the specified file number.
  265.  *
  266.  * Results:
  267.  *    SUCCESS if the entry is resident in the descriptor map.
  268.  *    FAILURE if the fileNumber is not available in the map.
  269.  *    
  270.  * Side effects:
  271.  *    None.
  272.  *
  273.  *----------------------------------------------------------------------
  274.  */
  275.  
  276. ReturnStatus
  277. LfsDescMapSetAccessTime(lfsPtr, fileNumber, accessTime)
  278.     Lfs      *lfsPtr;    /* File system of descriptor. */
  279.     int      fileNumber;   /* File number of descriptor. */ 
  280.     int  accessTime; /* New current access time.*/
  281. {
  282.     LfsDescMap          *mapPtr = &(lfsPtr->descMap);
  283.     LfsDescMapEntry   *entryPtr;
  284.     ReturnStatus      status;
  285.     LfsStableMemEntry    smemEntry;
  286.  
  287.     status = LfsStableMemFetch(&(mapPtr->stableMem), fileNumber, 
  288.                 LFS_STABLE_MEM_MAY_DIRTY, &smemEntry);
  289.     if (status != SUCCESS) {
  290.     return status;
  291.     }
  292.     entryPtr = (LfsDescMapEntry *) LfsStableMemEntryAddr(&smemEntry);
  293.  
  294.     if (!(entryPtr->flags & LFS_DESC_MAP_ALLOCED)) {
  295.     status = FAILURE;
  296.     } else { 
  297.     entryPtr->accessTime = accessTime;
  298.     }
  299.     LfsStableMemRelease(&(mapPtr->stableMem), &smemEntry, (status == SUCCESS));
  300.  
  301.     return status;
  302.  
  303. }
  304.  
  305.  
  306. /*
  307.  *----------------------------------------------------------------------
  308.  *
  309.  * Lfs_GetNewFileNumber --
  310.  *
  311.  *    Allocate an used file number for a newly created file or directory.
  312.  *
  313.  * Results:
  314.  *    An error if could not find a free file descriptor.
  315.  *    SUCCESS if a file number can be allocate.
  316.  *    FAILURE if all available file numbers are taken.
  317.  *    
  318.  * Side effects:
  319.  *    None.
  320.  *
  321.  *----------------------------------------------------------------------
  322.  */
  323.  
  324. ReturnStatus
  325. Lfs_GetNewFileNumber(domainPtr, dirFileNum, fileNumberPtr)
  326.     Fsdm_Domain     *domainPtr;    /* Domain to allocate the file 
  327.                      * descriptor out of. */
  328.     int     dirFileNum;    /* File number of the directory that
  329.              * the file is in.  -1 means that
  330.              * this file descriptor is being
  331.              * allocated for a directory. */
  332.     int    *fileNumberPtr; /* Place to return the file number allocated. */
  333. {
  334.     Lfs    *lfsPtr = LfsFromDomainPtr(domainPtr);
  335.     LfsDescMap          *mapPtr = &(lfsPtr->descMap);
  336.     register LfsDescMapEntry   *entryPtr;
  337.     register int maxNumDesc, startDesc, i;
  338.     Boolean    found = FALSE;
  339.     ReturnStatus      status;
  340.     static    int dirSeed = 0;
  341.     LfsStableMemEntry    smemEntry;
  342.  
  343.     maxNumDesc = mapPtr->params.maxDesc;
  344.     LFS_STATS_INC(lfsPtr->stats.desc.getNewFileNumber);
  345.     if (dirFileNum == -1) {
  346.     if (dirSeed == 0) {
  347.         dirSeed = Fsutil_TimeInSeconds();
  348.     } 
  349.         /*
  350.          * Search linearly from a random starting descriptor.
  351.          */
  352.         startDesc = ((dirSeed * 1103515245 + 12345) & 0x7fffffff) %
  353.                         maxNumDesc;
  354.     dirSeed++;
  355.     } else {
  356.     startDesc = dirFileNum;
  357.     }
  358.     status = LfsStableMemFetch(&(mapPtr->stableMem), startDesc, 
  359.             LFS_STABLE_MEM_MAY_DIRTY,
  360.             &smemEntry);
  361.     if (status != SUCCESS) {
  362.     return status;
  363.     }
  364.     entryPtr = (LfsDescMapEntry *) LfsStableMemEntryAddr(&smemEntry);
  365.     i = startDesc;
  366.     do { 
  367.     if (!(entryPtr->flags & LFS_DESC_MAP_ALLOCED)) {
  368.         found = TRUE;
  369.         break;
  370.     }
  371.     LFS_STATS_INC(lfsPtr->stats.desc.scans);
  372.     i++;
  373.         if (i == maxNumDesc) {
  374.         i = 0;
  375.     }
  376.     status = LfsStableMemFetch(&(mapPtr->stableMem), i, 
  377.             (LFS_STABLE_MEM_MAY_DIRTY| 
  378.              LFS_STABLE_MEM_REL_ENTRY), &smemEntry);
  379.     if (status != SUCCESS) {
  380.         return status;
  381.     }
  382.     entryPtr = (LfsDescMapEntry *) LfsStableMemEntryAddr(&smemEntry);
  383.    } while (i != startDesc);
  384.     if (!found) {    
  385.     LfsStableMemRelease(&(mapPtr->stableMem), &smemEntry, FALSE);
  386.         printf( "Out of file descriptors.\n");
  387.     return FAILURE;
  388.     }
  389.     mapPtr->checkPoint.numAllocDesc++;
  390.     LfsSetNilDiskAddr(&entryPtr->blockAddress);
  391.     entryPtr->flags = LFS_DESC_MAP_ALLOCED;
  392.     *fileNumberPtr = i;
  393.     LfsStableMemRelease(&(mapPtr->stableMem), &smemEntry, TRUE);
  394.     return SUCCESS;
  395. }
  396.  
  397.  
  398. /*
  399.  *----------------------------------------------------------------------
  400.  *
  401.  * Lfs_FreeFileNumber() --
  402.  *
  403.  *    Mark a file number as unused and make it available for re-allocation.
  404.  *
  405.  * Results:
  406.  *    SUCCESS if a file number was not allocated.
  407.  *    FAILURE if all available file numbers are taken.
  408.  *    
  409.  * Side effects:
  410.  *    Descriptor map entry is modified for the file.
  411.  *
  412.  *----------------------------------------------------------------------
  413.  */
  414.  
  415. ReturnStatus
  416. Lfs_FreeFileNumber(domainPtr, fileNumber)
  417.     Fsdm_Domain     *domainPtr;    /* Domain of the file descriptor. */
  418.     int      fileNumber;   /* File number to free. */
  419. {
  420.     Lfs    *lfsPtr = LfsFromDomainPtr(domainPtr);
  421.     LfsDescMap          *mapPtr = &(lfsPtr->descMap);
  422.     LfsDescMapEntry   *entryPtr;
  423.     ReturnStatus      status;
  424.     LfsStableMemEntry    smemEntry;
  425.  
  426.     LFS_STATS_INC(lfsPtr->stats.desc.free);
  427.  
  428.     status = LfsStableMemFetch(&(mapPtr->stableMem), fileNumber, 
  429.             LFS_STABLE_MEM_MAY_DIRTY, &smemEntry);
  430.     if (status != SUCCESS) {
  431.     return status;
  432.     }
  433.     entryPtr = (LfsDescMapEntry *) LfsStableMemEntryAddr(&smemEntry);
  434.  
  435.     if (!(entryPtr->flags & LFS_DESC_MAP_ALLOCED)) {
  436.     status = FAILURE;
  437.     } else { 
  438.     entryPtr->flags &= ~LFS_DESC_MAP_ALLOCED;
  439.     LfsSegUsageFreeBlocks(lfsPtr, sizeof(LfsFileDescriptor), 1, 
  440.               &entryPtr->blockAddress);
  441.     LfsSetNilDiskAddr(&entryPtr->blockAddress);
  442.     mapPtr->checkPoint.numAllocDesc--;
  443.     }
  444.     LfsStableMemRelease(&(mapPtr->stableMem), &smemEntry, (status == SUCCESS));
  445.     return status;
  446. }
  447.  
  448.  
  449.  
  450. extern ReturnStatus LfsDescMapAttach _ARGS_((Lfs *lfsPtr, int checkPointSize, 
  451.         char *checkPointPtr));
  452. extern Boolean LfsDescMapCheckpoint _ARGS_((LfsSeg *segPtr, int flags, 
  453.         char *checkPointPtr, int *checkPointSizePtr, 
  454.         ClientData *clientDataPtr));
  455. extern Boolean LfsDescMapLayout _ARGS_((LfsSeg *segPtr, int flags, 
  456.         ClientData *clientDataPtr));
  457. extern void LfsDescMapWriteDone _ARGS_((LfsSeg *segPtr, int flags,
  458.         ClientData *clientDataPtr));
  459. extern Boolean LfsDescMapClean _ARGS_((LfsSeg *segPtr, int *sizePtr, 
  460.         int *numCacheBlocksPtr, ClientData *clientDataPtr));
  461. extern ReturnStatus LfsDescMapDetach _ARGS_((Lfs *lfsPtr));
  462.  
  463. static LfsSegIoInterface descMapIoInterface = 
  464.     { LfsDescMapAttach, LfsDescMapLayout, LfsDescMapClean,
  465.       LfsDescMapCheckpoint, LfsDescMapWriteDone, LfsDescMapDetach, 0};
  466.  
  467.  
  468. /*
  469.  *----------------------------------------------------------------------
  470.  *
  471.  * LfsDescMapInit --
  472.  *
  473.  *    Initialize the the descriptor map data structures.  
  474.  *
  475.  * Results:
  476.  *    None
  477.  *    
  478.  * Side effects:
  479.  *
  480.  *----------------------------------------------------------------------
  481.  */
  482.  
  483. void
  484. LfsDescMapInit()
  485. {
  486.     LfsSegIoRegister(LFS_DESC_MAP_MOD,&descMapIoInterface);
  487. }
  488.  
  489.  
  490. /*
  491.  *----------------------------------------------------------------------
  492.  *
  493.  * DescMapAttach --
  494.  *
  495.  *    Attach routine for the descriptor map. Creates and initializes the
  496.  *    map for this file system.
  497.  *
  498.  * Results:
  499.  *    SUCCESS if attaching is going ok.
  500.  *
  501.  * Side effects:
  502.  *    Many
  503.  *
  504.  *----------------------------------------------------------------------
  505.  */
  506.  
  507. ReturnStatus
  508. LfsDescMapAttach(lfsPtr, checkPointSize, checkPointPtr)
  509.     Lfs   *lfsPtr;         /* File system for attach. */
  510.     int   checkPointSize;    /* Size of checkpoint data. */
  511.     char  *checkPointPtr;     /* Data from last checkpoint before shutdown. */
  512. {
  513.     LfsDescMap          *mapPtr = &(lfsPtr->descMap);
  514.     LfsDescMapCheckPoint *cp = (LfsDescMapCheckPoint *) checkPointPtr;
  515.     ReturnStatus    status;
  516.     int            size;
  517.  
  518.     /*
  519.      * Allocate and fill in memory data structure for descriptor map.
  520.      */
  521.     mapPtr->params = lfsPtr->superBlock.descMap;
  522.     mapPtr->checkPoint = *cp;
  523.     /*
  524.      * Load the index and buffer using the LfsStableMem routines.
  525.      */
  526.     size = sizeof(LfsDescMapCheckPoint);
  527.     status = LfsStableMemLoad(lfsPtr, &(mapPtr->params.stableMem), 
  528.             checkPointSize - size,
  529.             checkPointPtr + size,
  530.             &(mapPtr->stableMem));
  531.     if (status != SUCCESS) {
  532.     LfsError(lfsPtr, status, "Can't loading descriptor map index\n");
  533.     return status;
  534.     }
  535.  
  536.     printf("LfsDescMapAttach - %d allocated descriptors.\n", 
  537.         mapPtr->checkPoint.numAllocDesc);
  538.     return status;
  539. }
  540.  
  541. /*
  542.  *----------------------------------------------------------------------
  543.  *
  544.  * DescMapDetach --
  545.  *
  546.  *    Detach routine for the descriptor map. Destory the
  547.  *    map for this file system.
  548.  *
  549.  * Results:
  550.  *    SUCCESS if attaching is going ok.
  551.  *
  552.  * Side effects:
  553.  *    Many
  554.  *
  555.  *----------------------------------------------------------------------
  556.  */
  557.  
  558. ReturnStatus
  559. LfsDescMapDetach(lfsPtr)
  560.     Lfs   *lfsPtr;         /* File system for attach. */
  561. {
  562.     LfsDescMap          *mapPtr = &(lfsPtr->descMap);
  563.     return LfsStableMemDestory(lfsPtr, &(mapPtr->stableMem));
  564. }
  565.  
  566. /*
  567.  *----------------------------------------------------------------------
  568.  *
  569.  * DescMapCheckpoint --
  570.  *
  571.  *    Routine to handle checkpointing of the descriptor map data.
  572.  *
  573.  * Results:
  574.  *    TRUE if more data needs to be written, FALSE if this module is
  575.  *    checkpointed.
  576.  *
  577.  * Side effects:
  578.  *    Many
  579.  *
  580.  *----------------------------------------------------------------------
  581.  */
  582.  
  583. Boolean
  584. LfsDescMapCheckpoint(segPtr, flags, checkPointPtr, checkPointSizePtr, 
  585.             clientDataPtr)
  586.     LfsSeg *segPtr;        /* Segment containing data for checkpoint. */
  587.     int       flags;        /* Flags for shutdown */
  588.     char   *checkPointPtr;      /* Buffer to write checkpoint data. */
  589.     int       *checkPointSizePtr;  /* Bytes added to the checkpoint area.*/
  590.     ClientData *clientDataPtr;    
  591. {
  592.     Lfs              *lfsPtr = segPtr->lfsPtr;
  593.     LfsDescMap          *mapPtr = &(lfsPtr->descMap);
  594.     LfsDescMapCheckPoint *cp = (LfsDescMapCheckPoint *) checkPointPtr;
  595.     int        size, dataSize;
  596.     Boolean    full;
  597.  
  598.     *cp = mapPtr->checkPoint;
  599.     size = sizeof(LfsDescMapCheckPoint);
  600.     dataSize = 0;
  601.     full = LfsStableMemCheckpoint(segPtr, checkPointPtr + size, flags,
  602.             &dataSize, clientDataPtr, &(mapPtr->stableMem));
  603.     if (!full) { 
  604.     (*checkPointSizePtr) = dataSize + size;
  605.     }
  606.     return full;
  607.  
  608. }
  609.  
  610. /*
  611.  *----------------------------------------------------------------------
  612.  *
  613.  * LfsDescMapLayout --
  614.  *
  615.  *    Routine to handle writing of the descriptor map data.
  616.  *
  617.  * Results:
  618.  *    TRUE if more data needs to be written, FALSE if this module is
  619.  *    statisified
  620.  *
  621.  * Side effects:
  622.  *    Many
  623.  *
  624.  *----------------------------------------------------------------------
  625.  */
  626. Boolean
  627. LfsDescMapLayout(segPtr, flags, clientDataPtr)
  628.     LfsSeg *segPtr;        /* Segment to place data blocks in. */
  629.     int    flags;        /* Flags. */
  630.     ClientData    *clientDataPtr;
  631. {
  632.     Lfs              *lfsPtr = segPtr->lfsPtr;
  633.     LfsDescMap          *mapPtr = &(lfsPtr->descMap);
  634.  
  635.     if ((flags & LFS_CLEANING_LAYOUT) != 0) {
  636.     return FALSE;
  637.     }
  638.     return LfsStableMemLayout(segPtr, flags, clientDataPtr, &(mapPtr->stableMem));
  639. }
  640.  
  641. /*
  642.  *----------------------------------------------------------------------
  643.  *
  644.  * DescWriteDone --
  645.  *
  646.  *    Routine to handle finishing of a checkpoint.
  647.  *
  648.  * Results:
  649.  *    None
  650.  *
  651.  * Side effects:
  652.  *    Many
  653.  *
  654.  *----------------------------------------------------------------------
  655.  */
  656.  
  657. void
  658. LfsDescMapWriteDone(segPtr, flags, clientDataPtr)
  659.     LfsSeg *segPtr;        /* Segment containing data for checkpoint. */
  660.     int       flags;        /* Flags for checkpoint */
  661.     ClientData *clientDataPtr;
  662. {
  663.     Lfs              *lfsPtr = segPtr->lfsPtr;
  664.     LfsDescMap          *mapPtr = &(lfsPtr->descMap);
  665.  
  666.     LFS_STATS_ADD(lfsPtr->stats.desc.mapBlocksWritten,
  667.         (LfsSegSummaryBytesLeft(segPtr) / sizeof(int)));
  668.  
  669.     LfsStableMemWriteDone(segPtr, flags, clientDataPtr, &(mapPtr->stableMem));
  670.     return;
  671.  
  672. }
  673.  
  674.  
  675. /*
  676.  *----------------------------------------------------------------------
  677.  *
  678.  * DescMapClean --
  679.  *
  680.  *    Routine to handle cleaning of descriptor map data.
  681.  *
  682.  * Results:
  683.  *    TRUE if more data needs to be written, FALSE if this module is
  684.  *    happy for the time being.
  685.  *
  686.  * Side effects:
  687.  *    
  688.  *
  689.  *----------------------------------------------------------------------
  690.  */
  691.  
  692. Boolean
  693. LfsDescMapClean(segPtr, sizePtr, numCacheBlocksPtr, clientDataPtr)
  694.     LfsSeg *segPtr;    /* Segment containing data to clean. */
  695.     int       *sizePtr;        /* Segment to place data blocks in. */
  696.     int *numCacheBlocksPtr;
  697.     ClientData *clientDataPtr;
  698. {
  699.     Lfs              *lfsPtr = segPtr->lfsPtr;
  700.     LfsDescMap          *mapPtr = &(lfsPtr->descMap);
  701.     Boolean full;
  702.  
  703.     full =  LfsStableMemClean(segPtr, sizePtr, numCacheBlocksPtr, 
  704.         clientDataPtr, &(mapPtr->stableMem));
  705.  
  706.     LFS_STATS_ADD(lfsPtr->stats.desc.mapBlockCleaned,
  707.         *sizePtr/mapPtr->stableMem.params.blockSize);
  708.     return full;
  709. }
  710.  
  711.